package com.cloud.rocketmq.listener;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "rocketMqTransaction", consumerGroup = "OrderReceive")
//topic要与生产者的topic一致
public class TransactionConsumer implements RocketMQListener<MessageExt> {
    //    @Override
    public void onMessage(MessageExt message) {
        // 获取消息的 MessageId
        String messageId = message.getMsgId();
        System.out.println("TransactionConsumer线程" + Thread.currentThread() + "内容为:"
                + new String(message.getBody()) +
                "队列序号:" + message.getQueueId());
    }
}